﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data.SqlClient;
using System.Configuration;
using PsychveyApp1.classes;

namespace PsychveyApp1
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdminUserSignIn_Click(object sender, EventArgs e)
        {
            UserAccount useraccount = new UserAccount();
            string usertext = tbxAdminUsername.Text;
            Session["username"] = usertext; 
            string passtext = tbxAdminPassword.Text;
            Session["password"] = passtext; 

            useraccount = DBManager.UserLogin(usertext,passtext);
                if(!useraccount.username.Equals(""))
                {
                    if (useraccount.accountTypeSelected == "Administrator")
                    {
                        Session["currentUser"] = useraccount;
                        Response.Redirect("AdminHome.aspx");
                    }
                    else if (useraccount.accountTypeSelected == "Premium")
                    {
                        lblAdminStatus.Text = ("This account requires Administrative priviledges!");
                    }
                    else if (useraccount.accountTypeSelected == "Basic")
                    {
                        lblAdminStatus.Text = ("This account requires Administrative priviledges!");
                    }
                    else
                    {
                        lblAdminStatus.Text = ("Username or password is incorrect!");
                    }
                }
                else 
                {
                    lblAdminStatus.Text = ("Please fill up to sign in!");
                }

            }
              
        }
    }
  